package com.worksmap.core.task.support;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 任务执行器单例构造工厂
 * 
 * @author Chris Gao
 * 
 */
public class TaskExecutorFactory {
	
	private static Executor executor = null;
	
	public static Executor newExecutor(int poolSize) {
		if(executor == null){
			executor = new ThreadPoolExecutor(poolSize, poolSize, 0L,
					TimeUnit.MILLISECONDS, new FixedBlockingQueue<Runnable>(
							poolSize));
		}
		return executor;
	}
}
